package com.milhouz.bomberrokon.model;

import java.util.Random;

/** Items availables in the map model */
public class ItemsMapModel {

	private int nbFlamItems;
	private int nbBombItems;
	private int nbSpeedItems;

	public int getNbFlamItems() {
		return nbFlamItems;
	}

	public void setNbFlamItems(int nbFlamItems) {
		this.nbFlamItems = nbFlamItems;
	}

	public int getNbBombItems() {
		return nbBombItems;
	}

	public void setNbBombItems(int nbBombItems) {
		this.nbBombItems = nbBombItems;
	}

	public int getNbSpeedItems() {
		return nbSpeedItems;
	}

	public void setNbSpeedItems(int nbSpeedItems) {
		this.nbSpeedItems = nbSpeedItems;
	}

	/** Get item type randomly : -1=nothing, 0=flam, 1=bomb, 2=speed */
	public int getItemTypeRandomly() {
		Random r = new Random();
		if (r.nextInt(2) == 0) {
			int item = r.nextInt(3);
			if (item == 2 && nbSpeedItems != 0) {
				nbSpeedItems--;
				return 2;
			} else if (item == 0 && nbFlamItems != 0) {
				nbFlamItems--;
				return 0;
			} else if (item == 1 && nbBombItems != 0) {
				nbBombItems--;
				return 1;
			}
		}
		return -1;
	}
}
